/**
 * 
 */
package multimedia.util;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Scanner;
import java.util.Vector;

/**
 * @author trigueros
 * 
 */
public class DatabaseInterfacer
{
    public static int databaseImageCount = 0;
    
    public static void WriteToDatabase( String filename, Vector<String> outputData )
    {
        try
        {
            BufferedWriter out = new BufferedWriter(new FileWriter(new File(filename), true));
            
            // Write entire Vector
            for( int i = 0; i < outputData.size(); i++ )
                out.write(outputData.get(i) + "\n");
            
            out.close();
        } catch ( IOException e )
        {
            e.printStackTrace();
        }
    }
    
    public static Vector<String> ReadDatabase( String filename )
    {
        Vector<String> db = new Vector<String>();
        try
        {
            Scanner dbReader = new Scanner( new File( filename ));
            while( dbReader.hasNextLine() )
                db.add( dbReader.nextLine() );
            
        } catch ( FileNotFoundException e )
        {
            e.printStackTrace();
        }
        
        return db;
    }
}
